package javax.util;

import java.util.HashMap;
import java.util.Map;

import com.kinyx.framework.annotation.assist.CanNotNull;
import com.kinyx.framework.annotation.assist.CanNull;
import com.kinyx.framework.annotation.assist.Note;
import com.kinyx.framework.annotation.assist.ReturnNotNull;

/**
 * 扩展实现HashMap
 * @param <K> 键泛型
 * @param <V> 值泛型
 * @see java.util.HashMap
 */
@SuppressWarnings("serial")
public final class XHashMap<K, V> extends HashMap<K, V> {

	public XHashMap() { super(); }

	public XHashMap(final int initialCapacity, final float loadFactor) { super(initialCapacity, loadFactor); }

	public XHashMap(final int initialCapacity) { super(initialCapacity); }

	public XHashMap(final Map<? extends K, ? extends V> m) { super(m); }

	/**
	 * 增加元素
	 * @param key 键
	 * @param value 值
	 * @return 本对象
	 */
	@ReturnNotNull
	@Note("return this;")
	public XHashMap<K, V> xPut(@CanNull final K key, @CanNull final V value) {
		this.put(key, value);
		return this;
	}

	/**
	 * 增加元素集合
	 * @param map 集合
	 * @return 本对象
	 */
	@ReturnNotNull
	@Note("return this;")
	public XHashMap<K, V> xPutAll(@CanNotNull final Map<? extends K, ? extends V> map) {
		this.putAll(map);
		return this;
	}

}
